
layui.use(['form', 'element'], function(){
    var element = layui.element; //导航的hover效果、二级菜单等功能，需要依赖element模块
    
    //监听导航点击
    element.on('nav(demo)', function(elem){
    //console.log(elem)
    layer.msg(elem.text());
    });
    });

layui.use(['upload', 'element'], function () {
    let upload = layui.upload;//实例化upload模块对象
    let element = layui.element;

    //拖拽上传
    upload.render({
        elem: '#test10'
        , url: '../img' //改成您自己的上传接口
        , done: function (res) {
            console.log(res)
            layer.msg('上传成功');
            layui.$('#uploadDemoView').removeClass('layui-hide').find('img').attr('src', '../img/' + res.data);
        },
        progress: function (n, elem) {
            let percent = n + '%' //获取进度百分比
            element.progress('demo', percent); //可配合 layui 进度条元素使用

            //以下系 layui 2.5.6 新增
            console.log(elem); //得到当前触发的元素 DOM 对象。可通过该元素定义的属性值匹配到对应的进度条。
        }
    });
})